package com.xhs.main.service.yfb.impl;

import com.xhs.main.dao.yfb.YfbTestMapper;
import com.xhs.main.entity.yfb.YfbTest;
import com.xhs.main.entity.yfb.YfbTestExample;
import com.xhs.main.service.yfb.YfbTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @create 2020-10-22 23:35
 */
@Service
public class YfbTestServiceImpl implements YfbTestService {
    @Autowired
    YfbTestMapper yfbTestMapper;

    @Override
    public void createTest(YfbTest yfbTest) {
            yfbTestMapper.insert(yfbTest);
    }

    @Override
    public List<YfbTest> queryAllTests() {
        return yfbTestMapper.selectByExample(new YfbTestExample());
    }

    @Override
    public List<YfbTest> queryTestByItemId(String itemId) {
        YfbTestExample example = new YfbTestExample();
        YfbTestExample.Criteria criteria = example.createCriteria();
        //条件查项目表主键
        criteria.andYfbTestItemIdEqualTo(itemId);
        return yfbTestMapper.selectByExample(example);
    }

    @Override
    public List<YfbTest> queryTestByDevelop(String develop) {
        YfbTestExample example = new YfbTestExample();
        YfbTestExample.Criteria criteria = example.createCriteria();
        //条件查开发分类：软硬
        criteria.andYfbTestDevelopsortEqualTo(develop);
        return yfbTestMapper.selectByExample(example);
    }

    @Override
    public List<YfbTest> queryTestByItemIdAndDevelop(String itemId, String develop) {
        YfbTestExample example = new YfbTestExample();
        YfbTestExample.Criteria criteria = example.createCriteria();
        //条件查项目表主键
        criteria.andYfbTestItemIdEqualTo(itemId);
        //条件查开发分类：软硬
        criteria.andYfbTestDevelopsortEqualTo(develop);
        return yfbTestMapper.selectByExample(example);
    }
}
